<template>
  <div class="promotion">
    <van-swipe :autoplay="3000" v-if="item.banner">
      <van-swipe-item
        v-for="(image, index) in item.banner"
        :key="index"
        class="banner"
      >
        <van-image :src="image.img" />
      </van-swipe-item>
    </van-swipe>

    <div class="title acea-row row-center-wrapper">
      <div class="line"></div>
      <div class="name">
        <van-icon name="bill-o" />
        <span>促销单品</span>
      </div>
      <div class="line"></div>
    </div>

    <div class="benefit">
      <div v-for="l in item.list" class="item" :key="l.id">
        <router-link to="/a">
          <van-image :src="l.image" alt="" />
          <div class="right">
            <p class="text">{{ l.store_name }}</p>
            <div class="pri">
              <span>促销价：￥{{ l.price }}</span>
            </div>
            <div class="del">
              <div class="money">日常价：￥{{ l.ot_price }}</div>
              <div class="residue">仅剩：{{ l.stock }}{{ l.unit_name }}</div>
            </div>
          </div>
        </router-link>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      item: [],
    };
  },
  created() {
    this.$axios.get("/api/groom/list/4?page=1").then((d) => {
      console.log(d);
      this.item = d.data.data;
    });
  },
};
</script>

<style lang="less" scoped>
.promotion {
  .title {
    height: 1.2rem;
    font-size: 0.4rem;
    color: #282828;
    background: rgb(245, 245, 245);
    display: flex;
    align-items: center;
    justify-content: center;

    .line {
      width: 2.3rem;
      height: 0.04rem;
      background-color: #e9e9e9;
    }
    .name {
      margin: 0 0.2rem;

      span {
        font-size: 0.38rem;
        vertical-align: middle;
      }
      i {
        vertical-align: middle;
      }
    }
  }

  .benefit {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 10px;
    box-sizing: border-box;
    .item {
      padding: 0;
      margin: 0;
      a {
        width: 100%;
        height: 4rem;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        margin: 5px 0;
        border-bottom: 1px solid rgb(220, 220, 220);
      }
      .van-image {
        width: 3rem;
        height: 3rem;
        margin-left: 10px;
      }
      .right {
        flex: 1;
        height: 3rem;
        margin-left: 10px;
        margin-right: 10px;
        .text {
          font-size: 0.4rem;
          color: rgb(51, 51, 51);
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 1;
          overflow: hidden;
          text-align: left;
        }
        .pri {
          text-align: left;
          margin: 1rem 0 0.3rem 0;
          height: 0.5rem;
          span {
            display: inline-block;
            height: 0.5rem;
            padding: 0 10px;
            font-size: 0.3rem;
            background: rgb(255, 75, 45);
            color: white;
            line-height: 0.5rem;
            border-top-left-radius: 12px;
            border-bottom-right-radius: 12px;
          }
        }
        .del {
          color: #999;
          overflow: hidden;
          font-size: 0.3rem;
          .money {
            text-decoration: line-through;
            float: left;
          }
          .residue {
            float: right;
          }
        }
      }
    }
  }
}
</style>
